package com.fbinggun.fattribute.effect;

import com.fbinggun.fattribute.data.EntityData;
import org.bukkit.Sound;

public class BleedEffect extends IEffect{
    int tick=20;

    public BleedEffect(int duration, double modification,EntityData s) {
        super(duration, modification,s);
    }


    @Override
    public void tick(EntityData entityData) {
        tick--;
        if(tick!=0){
            return;
        }
        tick=20;
        double health = entityData.getEntity().getHealth();
        health=health-getModification();
        if(health<=0 ){
            health=0;
        }
        if(entityData.getEntity()!=null) {
            entityData.getEntity().setHealth(health);

            entityData.getEntity().getWorld().playSound(entityData.getEntity().getLocation(), Sound.ENTITY_PLAYER_HURT,1,1);
        }
        entityData.getEntity().sendMessage("§c流血 -"+getModification()+" HP");
        source.getEntity().sendMessage("§a你对"+entityData.getEntity().getName()+"造成了 流血 -"+getModification()+" HP");
    }
}
